package com.spring.proxy;

import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class TestPay {

    @Test
    public void payTest() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
       String str = "com.spring.proxy.Zhi";
//       if(str.equals("微信")){
//           new WeiXin().payOnline();
//       }else if(str.equals("支付宝")){
//           new Zhi().payOnline();
//       }else if(str.equals("中信")){
//         //  ....
//       }

        // 动态生成
        Class aClass = Class.forName(str);
        Method payOnline = aClass.getMethod("payOnline");
        Object o = aClass.newInstance();
        payOnline.invoke(o);
    //sping ioc





//
    }
}
